<?php
  require_once 'DB.php';
  include_once("./libraries/db.inc.php");
  include_once("./libraries/authentication.inc.php");
  include_once("./queries/jobQueue.inc.php");
  include_once("./libraries/util.inc.php");
  include_once("./libraries/displayUtils.inc.php");
  

  session_start();
  sessionAuthenticate("login.php");

  $cid = $_GET["cid"];  
  $pid = $_GET["pid"];
  $schedd = $_GET["schedd"];

  setUpDisplay("Job in Queue Info");

  $connection=DB::connect($dsn, $options);
  if (DB::isError($connection)) {
    trigger_error($connection->getMessage(), E_USER_ERROR);
  }
  
  


  echo "<font size=5><center><b>In process Proc Info</b></center></font><br />\n";
  echo "<font size=5><center><b>for job: '{$schedd}'.{$cid}.{$pid}.</b></center></font><br />\n"; 
  printLink("./index.php", "Take me back to the main page!");
  echo "\n";
  if ($_SESSION["administrator"] === true) {
    echo "<br /><p>\n";
    printLink("./adminIndex.php", "Take me back to the Admin screen!");
  }
  echo "<br /><br /><b>Here is classad info:</b><br />\n";
  $dataIndex="procInfoShort";
  $rs = single_proc_short_query($connection, $dataIndex, $schedd, $cid, $pid);
  if ($_SESSION["administrator"] === true) {
		  //$rs->setLinkParams(0, array("mid"), array(0), "machineInfo.php");
  }
  $rs->printTable();

  printLink("./procInfoLong.php?cid={$cid}&pid={$pid}&schedd={$schedd}", 
             "See the complete class ad");  
  echo "<br /><br /><b>Here is info about runs of the proc:</b><br />\n";
  $dataIndex="procInfoRuns";
  $rs = single_proc_runs_query($connection, $dataIndex, $schedd, $cid, $pid);
  if ($_SESSION["administrator"] === true) { 
		  //$rs->setLinkParams(1, array("mid"), array(1), "machineInfo.php");
  }
  $rs->printTable();

	// events related
  echo "<br /><br /><b>Here is info about events of the proc:</b><br />\n";
  $dataIndex="procInfoEvents";
  $rs = single_proc_events_query($connection, $dataIndex, $schedd, $cid, $pid);
  if ($_SESSION["administrator"] === true) { 
		  //$rs->setLinkParams(1, array("mid"), array(1), "machineInfo.php");
  }
  $rs->printTable();

  echo "<br /><br /><b>Here is rolled-up info about matches:</b><br />\n";
  $dataIndex="procInfoMatchesRollup";
  $rs = single_proc_matches_summary($connection, $dataIndex, $schedd, $cid, $pid);
  $rs->setLinkParams(0, array("schedd", "cid", "pid", "matchTime"),
                       array(1,2,3,0), "matchList.php");
  if ($_SESSION["administrator"] === true) {
		  // $rs->setLinkParams(1, array("mid"), array(1), "machineInfo.php");
    $rs->setLinkParams(4, array("mid"), array(4), "machineInfo.php");
  }
  //$rs->complexSetLinkParams(0, array("schedd", "cid", "pid", "matchTime"), 
  //                             array(1,2,3,0));
  //$rs->linkFile="matchList.php";
  $rs->printTable();

  echo "<br /><br /><b>Here is rolled-up info about rejects in the last hour:</b><br />\n";
  $dataIndex="procInfoRejectsRollup";
  $rs = single_proc_rejects_summary($connection, $dataIndex, $schedd, $cid, $pid);
  //$rs->setLinkParams(0, array("schedd", "cid", "pid", "rejectTime"),
  //                      array(1,2,3,0), "rejectList.php");
  //if ($_SESSION["administrator"] === true) { 
  //  $rs->setLinkParams(1, array("mid"), array(1), "machineInfo.php"); 
  //}
  //$rs->complexSetLinkParams(0, array("schedd", "cid", "pid", "rejectTime"), 
  //                             array(1,2,3,0));
  //$rs->linkFile="rejectList.php";
  $rs->printTable();

  cdbFinishPage();
  $connection->disconnect();

?>
